//
//  SEDoctorDetailCommentCell.swift
//  SmartEyeForPatient
//
//  Created by QDSG on 2021/4/12.
//

import UIKit

class SEDoctorDetailCommentCell: UITableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        backgroundColor = .white
        contentView.backgroundColor = .white
    }

    func updateWithViewModel(_ model: SEDoctorCommentDetail) {
        avatarImageView.kf.setAvatarImage(urlString: model.creatorPhoto)
        timeLabel.text = Date.dateStringFormatToString(model.createTime, inputFormat: "yyyy-MM-dd HH:mm:ss", outputFormat: "yyyy-MM-dd")
        nameLabel.text = model.creatorName
        commentLabel.text = model.detail
        starView.currentStarCount = Float(model.rank)
    }
    
    @IBOutlet private weak var avatarImageView: UIImageView!{
        didSet {
            avatarImageView.layer.cornerRadius = avatarImageView.height / 2.0
            avatarImageView.layer.masksToBounds = true
        }
    }
    @IBOutlet private weak var nameLabel: UILabel!
    @IBOutlet private weak var timeLabel: UILabel!
    @IBOutlet private weak var commentLabel: UILabel!
    @IBOutlet private weak var starView: SEStarRatingView! {
        didSet {
            starView.drawStar(margin: 2, isFill: true)
            starView.drawStar(margin: 2, isFill: false)
        }
    }
    
}
